%{
#include "parser.h"
#include "tree.h"

#ifdef DUMP_TOKENS
    #define RETURN(t) do {                                          \
        fprintf ( stderr, "TOKEN ( %d,\t'%s' )\n", t, yytext );     \
        return t;                                                   \
    } while ( 0 )
#else
    #define RETURN(t) return t
#endif
%}

%option array
%option noyywrap
%option yylineno

letter	 	[a-zA-Z_]

%%
.           				{ RETURN( yytext[0] ); }
[ \t\n]																	/* WHITESPACE */
"//".*\n																/* COMMENTS */
[0-9]+						{ yylval = atoi(yytext); return NUMBER; }	/* NUMBERS */
":="						{ return ASSIGN; }							/* ASSIGNMENT */
\"(\\\"|[^\"\n])*\"			{ return STRING; }							/* STRING */
"FUNC"						{ return FUNC; }
"PRINT"						{ return PRINT; }
"RETURN"					{ return RETURN; }
"CONTINUE"					{ return CONTINUE; }
"IF"						{ return IF; }
"THEN"						{ return THEN; }
"ELSE"						{ return ELSE; }
"FI"						{ return FI; }
"WHILE"						{ return WHILE; }
"DO"						{ return DO; }
"DONE"						{ return DONE; }
"VAR"						{ return VAR; }
{letter}({letter}|[0-9])* 	{ return IDENTIFIER; }

%%
